import { expect } from 'chai';
import time from '../src/time';

describe('time unit test', function() {
    it('should return empty string if no arguments is given', function() {
        expect(time.format()).to.eql('');
    });

    it('should return date for valid argument', function() {
        expect(time.format('%y/%m/%d', 1589776171)).to.eql('2020/05/18');
    });

    it('should return date time for valid argument', function() {
        expect(time.format('%y-%m-%d %h:%M:%s', 1589776171)).to.eql('2020-05-18 12:29:31');
    });

    it('should return date time for valid argument', function() {
        expect(time.format('%h:%M:%s', 1589776141)).to.eql('12:29:01');
    });

    it('should return true for the same day', function() {
        expect(time.isSameDay(1589731200, 1589776171)).to.be.true;
    });

    it('should return false for different days', function() {
        expect(time.isSameDay(1589731199, 1589776171)).to.be.false;
    });

    it('2000 is leap year', function() {
        expect(time.isLeap(2000)).to.be.true;
    });
    it('1900 is not leap year', function() {
        expect(time.isLeap(1900)).to.be.false;
    });
    it('2004 is leap year', function() {
        expect(time.isLeap(2004)).to.be.true;
    });
})
